<!-- Select Controle Score -->
<?php
require('db.php');

$competentie = $_GET['competentie'];
$vak = $_GET['vak'];

$result = mysql_query("SELECT b.id, b.cijfer, l.voornaam, k.studierichting
FROM behaaldecompetenties b, leerling l, klas k
WHERE b.competentiePerVakID IN (
  SELECT p.id
  FROM competentiespervak p
  WHERE p.vakID = (
    SELECT id
    FROM vak
    WHERE naam = '$vak'
  )
  AND p.id = $competentie
)
AND l.id = b.leerlingID
AND l.klas = k.id") or die (mysql_error());

$data = array();

while ($row = mysql_fetch_object($result)) {
    $data [] = $row;
}

echo json_encode($data);
?>
